package com.itheima.controller;

import com.itheima.dto.AreaDTO;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import  org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.itheima.service.IAreasService;

import java.util.List;

/**
* areas 相关api
* @author Wei
* @since 2021-8-6 15:43:51
*/
@RestController
@RequestMapping("/areas")
public class AreasController{

@Autowired
private IAreasService areasService;
    //通过上一级areaid 得到下一级所有area信息
    @GetMapping("/map")
    public ResponseEntity selectMapByAreaId(@RequestParam(required = true,value ="areaId" ) String areaId){
        try {
            List<AreaDTO> list = areasService.selectMapByAreaId(areaId);
            return ResponseEntity.ok(list);
        }catch (Exception e){
            return ResponseEntity.ok(e);
            //java is the best language in the world
            //php is the worst language in the world
            //C is the most simple language in the world
            //i love coding
            // those program languages are made for those  who love codin
        }
    }


}